{extend name="public:head"}
{block name="main"}

<label class="layui-form-label">权重最大:{$info_info.px} </label>
<label class="layui-form-label">A等级：{$info_info.first}个</label>
<label class="layui-form-label">B等级：{$info_info.secord}个</label>
<label class="layui-form-label">C等级：{$info_info.third}个</label>

<form id="add_from" style="margin: 15px" class="layui-form" method="post" action="/admin/Product/add/id/{$info['product_id']|default=''}">

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label ">推广等级</label>
        <div class="layui-input-inline">
            <select name="grade" id="#grade" lay-filter="grade" lay-verify="required"  autocomplete="off">
                <option value="">请选择推广等级</option>
                {volist name="gradeName" id="vo"}
                <option value="{$vo.grade_name}" {if $vo.grade_name  ==  $info['grade'] } selected="selected" {/if} >{$vo.grade_name}</option>
                {/volist}
            </select>
        </div>

        <label style="display: none" id="px_label" class="layui-form-label">排序</label>
        <div class="layui-input-inline">
            <input type="hidden" name="px" id="grade_px"  value="{$info['px']|default=''}" placeholder="" class="layui-input" lay-verify="required">
            <input type="hidden" name="product_id" value="{$info['product_id']|default=''}" class="layui-input">
        </div>

        <label class="layui-form-label">贷款分类</label>
        <div class="layui-input-inline">
            <select name="category_id" lay-filter="category" lay-verify="required"  autocomplete="off">
                <option value="">请选择贷款分类</option>
                {volist name="categoryName" id="vo"}
                <option value="{$vo.category_id}" {if $vo.category_id  ==  $info['category_id'] } selected="selected" {/if} >{$vo.category_name}</option>
                {/volist}
            </select>
        </div>

        <input type="checkbox" name="repeat" value="{$info.repeat}" lay-filter="repeat" id="repeat" title="重复出现" {if $info.repeat  == 1 } checked {/if}>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">产品标题</label>
        <div class="layui-input-block">
            <input type="text" name="title" placeholder="请输入标题"  class="layui-input" lay-verify="required" value="{$info['title']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label ">产品图片</label>
        <div class="layui-input-inline">
            <input type="text" id="img_upload_url" name="img_url" required   placeholder="图片地址"  class="layui-input" lay-verify="required" value="{$info['img_url']|default=''}">
        </div>
        <div class="layui-input-inline" style="width: 50px">
            <img style="width: 37px;height: auto" type="hidden" id="img_upload" src="{$info['img_url']}">
        </div>
        <div class="layui-input-inline">
            {notempty name="info['img_url']"}
            <img src="" id="img_url" class="content-photos" style="height: 35px">
            {/notempty}
            <a id="post_img" name="post_img" type="file" class="layui-btn layui-btn-small layui-btn-normal" data-name="thumb" style="margin-left:10px;">
                <i class="layui-icon">&#xe64a;</i>上传图片
            </a>
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label ">申请人数</label>
        <div class="layui-input-inline">
            <input type="text" name="application" required   placeholder="输入申请人数"  class="layui-input" value="{$info['application']|default=''}">
        </div>

        <label class="layui-form-label">成功申请</label>
        <div class="layui-input-inline">
            <input type="text" name="success_application" required   placeholder="输入成功申请人数"  class="layui-input" value="{$info['success_application']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">贷款额度</label>
        <div class="layui-input-inline" >
            <input type="text" name="price_min" placeholder="￥：最低额度"   class="layui-input"  lay-verify="required" value="{$info['price_min']|default=''}">
        </div>
        <!--<div class="layui-form-mid">-</div>-->
        <div class="layui-input-inline">
            <input type="text" name="price_max" placeholder="￥：最高额度"  class="layui-input"  lay-verify="required" value="{$info['price_max']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label ">期限范围</label>
        <div class="layui-input-inline">
            <input type="text" name="limit_time"  placeholder="输入期限范围"  class="layui-input" value="{$info['limit_time']|default=''}">
        </div>

        <label class="layui-form-label">日利息</label>
        <div class="layui-input-inline">
            <input type="text" name="day_interest" required   placeholder="输入日利息"  class="layui-input" lay-verify="required" value="{$info['day_interest']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label ">申请连接</label>
        <div class="layui-input-block">
            <input type="text" name="application_url" required   placeholder="请输入申请连接"  class="layui-input" lay-verify="required" value="{$info['application_url']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">产品介绍</label>
        <div class="layui-input-block">
            <input type="text" name="introduce"  placeholder="输入产品介绍"  class="layui-input"  value="{$info['introduce']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">审核说明</label>
        <div class="layui-input-block">
            <input type="text" name="application_check"  placeholder="审核说明"  class="layui-input" value="{$info['application_check']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">申请条件</label>
        <div class="layui-input-block">
            <textarea id="build" name="application_condition"  placeholder="请输入" class="layui-textarea" >{$info['application_condition']|default=''}</textarea>
        </div>
    </div>

    <hr class="layui-bg-red">

    <div class="layui-form-item layui-form-pane" lay-filter="pay">
        <label class="layui-form-label">还款方式</label>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_zfb" lay-filter="pay_zfb" id="zfb" title="支付宝" {if $info.pay_zfb  == 1 } checked {/if}>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_wx" lay-filter="pay_wx" id="wx" title="微信" {if $info.pay_wx  == 1 } checked {/if}>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_app" lay-filter="pay_app" id="app" title="app" {if $info.pay_app  == 1 } checked {/if}>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_BankCard" lay-filter="pay_BankCard"  id="BankCard" title="银行卡" {if $info.pay_BankCard  == 1 } checked {/if}>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_web" lay-filter="pay_web" id="web" title="官网" {if $info.pay_web  == 1 } checked {/if}>
        <input type="checkbox" value="{$info.pay_zfb}" name="pay_Money" lay-filter="pay_Money" id="Money" title="现金" {if $info.pay_Money  == 1 } checked {/if}>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">服务热线</label>
        <div class="layui-input-block">
            <input type="text" name="phone_num"  placeholder="输入服务热线"  class="layui-input" value="{$info['phone_num']|default=''}">
        </div>
    </div>

    <div class="layui-form-item  layui-form-pane">
        <label class="layui-form-label">公司简介</label>
        <div class="layui-input-block">
            <textarea  name="introduction_company" placeholder="简单介绍公司" class="layui-textarea">{$info['introduction_company']|default=''}</textarea>
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">后台地址</label>
        <div class="layui-input-block">
            <input type="background" name="bg_url"  placeholder="后台地址"  class="layui-input" value="{$info['bg_url']|default=''}">
        </div>
    </div>

    <div class="layui-form-item layui-form-pane">
        <label class="layui-form-label">状态</label>
        <div class="layui-input-block">
            <input type="radio" name="status" value="1" title="上架" {if $info.status  == 1 } checked {/if}>
            <input type="radio" name="status" value="0" title="下架" {if $info.status  == 0 } checked {/if}>
        </div>
    </div>

    <div class="layui-form-item">
        <div class="layui-input-block">
            <button class="layui-btn" lay-submit="" lay-filter="formDemo">立即提交</button>
            <button type="reset" class="layui-btn layui-btn-primary">重置</button>
        </div>
    </div>

</form>

<script>
    // 引入form模块
    layui.use(['form','upload','layedit','layer'], function(){
        var layer = layui.layer;
        var form = layui.form;
        var upload = layui.upload;
        var layedit = layui.layedit;
        var index = layedit.build('build',{
            height: 180
        }); //建立编辑器

        form.on('submit(formDemo)', function(data){
            // console.log(layedit.getContent(index));
            // var object = data.field
            // console.log(object);
            // //layer.msg(JSON.stringify(data.field));
            // $.ajax({
            //     url :'/admin/Product/addProduct'
            //     ,data :object
            //     ,method : 'post'
            // })
        });

        upload.render({
            elem: '#post_img'
            ,url: '/admin/Upload/upload_img' //必填项
            ,auto: true
            ,accept: 'file'
            ,method: 'post' //可选项。HTTP类型，默认post
            ,contentType: true    //不可缺
            ,processData: false
            // ,data: {} //可选项。额外的参数，如：{id: 123, abc: 'xxx'}
            ,before: function(obj){ //obj参数包含的信息，跟 choose回调完全一致，可参见上文。
                layer.load(); //上传loading
            }
            ,done: function(res, index, upload){
                layer.closeAll('loading'); //关闭loading
                if(res.code == 200){
                    layer.msg('上传成功');
                    $("#img_upload_url").attr("value",res.path);
                    $("#img_upload").attr("type","");
                    $("#img_upload").attr("src",res.path);
                }
                console.log(res);
            }
        });
        // 监控下拉框
        form.on('select(grade)', function(data){

            console.log(data.value); //得到被选中的值
            var value = data.value;
            {volist name="gradeName" id="vo"}
            if(value == '{$vo.grade_name}'){
                $("#grade_px").attr("type","text");
                $("#px_label")
                $("#grade_px").attr("placeholder","{$vo.input_value}");
            }
            {/volist}
            if(value == ""){
                $("#px_label").attr("display","none");
                $("#grade_px").attr("type","hidden");
            }
        });
        var pay = new Array();
        // 监控支付方式单选框值
        form.on('checkbox(pay_zfb)', function(data){
            // console.log(data.elem.name); //得到checkbox原始DOM对象
            // console.log(data.elem.checked); //是否被选中，true或者false
            // console.log(data.value); //复选框value值，也可以通过data.elem.value得到
            // console.log(data.othis); //得到美化后的DOM对象

            data.elem.checked ? $('#zfb').attr("value",1) : $('#zfb').attr("value",0);
            form.render('checkbox','pay_zfb');
            console.log(data.value);
            //form.render('checkbox');
            //console.log(data.elem.value);
        });
        form.on('checkbox(pay_wx)', function(data){
            data.elem.checked ? $('#wx').attr("value",'1') : $('#wx').attr("value",0);
            form.render('checkbox','pay');
        });
        form.on('checkbox(pay_app)', function(data){
            data.elem.checked ? $('#app').attr("value",'1') : $('#app').attr("value",0);
            form.render('checkbox','pay');
        });
        form.on('checkbox(pay_BankCard)', function(data){
            data.elem.checked ? $('#BankCard').attr("value",'1') : $('#BankCard').attr("value",0);
            form.render('checkbox','pay');
        });
        form.on('checkbox(pay_web)', function(data){
            data.elem.checked ? $('#web').attr("value",'1') : $('#web').attr("value",0);
            form.render('checkbox','pay');
        });
        form.on('checkbox(pay_Money)', function(data){
            data.elem.checked ? $('#Money').attr("value",'1') : $('#Money').attr("value",0);
            form.render('checkbox','pay');
        });
        form.on('checkbox(repeat)', function(data){
            data.elem.checked ? $('#repeat').attr("value",'1') : $('#repeat').attr("value",0);
            form.render('checkbox','pay');
        });

        // $('#img_upload').on('click', function() {
        //     layer.open({
        //         type: 1,
        //         title: false,
        //         closeBtn: 0,
        //         area: '1200px',
        //         skin: 'layui-layer-nobg', //没有背景色
        //         shadeClose: true,
        //         content: $('#tong')
        //     });
        // });
        // ajax提交表格监听

    });

</script>


{/block}

